package com.fubowen.reader.db.bean

import androidx.annotation.IntDef
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

@Entity(indices = [Index(value = ["url"], unique = true)])
data class BookBean(
    @PrimaryKey(autoGenerate = true)
    var id: Int = 0,
    var name: String = "",
    var author: String? = null,
    var timestamp: Long = System.currentTimeMillis(),
    var isReading: Boolean = false,
    var url: String = "",
    var size: Long = 0,
    var chapterCount: Int = 0,
    @Type
    var type: Int = TYPE_LOCAL,
    val lastUpdateTime: Long = 0,
    val lastUpdateChapter: String = "",
    val lastUpdateChapterName: String = "",
    val readingChapter: Int = 0,
    val readingChapterName: String = ""
) {
    companion object {
        const val TYPE_LOCAL = 0
        const val TYPE_WEB = 1
        const val TYPE_FINISH = 2
    }

    @IntDef(TYPE_LOCAL, TYPE_WEB, TYPE_FINISH)
    @Retention(AnnotationRetention.SOURCE)
    annotation class Type
}
